<template>
  <div v-loading="loading" style="width: 100vw;height: 100vh;background: #EEEEEE">
  <top :isSecond="1" :title="title" />
  <el-form ref="Form" :rules="rules" :inline="true" :model="feedbackInfo" class="form">
    <el-form-item prop="type" style="width: 84vw;margin: 4vh auto;">
      <el-cascader
        style="width: 84vw;margin: 0 auto;"
        v-model="feedbackInfo.type"
        placeholder="请选择反馈类型"
        :options="typeOption"></el-cascader>
    </el-form-item>
    <el-form-item prop="content" style="width: 84vw;margin: 0 auto;">
      <el-input
        style="width: 84vw;height: 42vh;"
        type="textarea"
        :rows="16"
        maxlength="160"
        placeholder="请输入内容"
        show-word-limit
        resize="none"
        v-model="feedbackInfo.content" />
    </el-form-item>
    <el-button style="width: 84vw;margin: 4vh auto;" @click="submit">提交</el-button>
  </el-form>
  <bottom/>
</div>
</template>

<script>
import top from '@/components/top'
import bottom from '@/components/bottom'
export default {
  name: 'newFeedback',
  data () {
    return {
      loading: false,
      title: '新建反馈',
      feedbackInfo: {
        type: null,
        content: null,
        id: this.$store.state.usrInfo.id,
        time: null
      },
      rules: {
        type: [
          { required: true, message: '请选择类型', trigger: 'blur' }
        ],
        content: [
          { required: true, message: '请填写内容', trigger: 'blur' }
        ]
      },
      typeOption: [{ value: 'bug', label: 'bug' },
        { value: '学校', label: '学校' },
        { value: '学生', label: '学生' },
        { value: '寝室', label: '寝室' },
        { value: '其他', label: '其他' }]
    }
  },
  methods: {
    submit () {
      this.feedbackInfo.time = new Date()
      this.feedbackInfo.time = this.feedbackInfo.time.toLocaleDateString()
      this.$refs.Form.validate((e) => {
        if (e) {}
      })
    }
  },
  components: {
    top,
    bottom
  }

}
</script>

<style lang="stylus" scoped>
.form
  display flex
  align-items center
  justify-content flex-start
  flex-direction column
</style>
